macromedia Your Account International Help
Products Support & Training DevNet Solutions Partners Downloads Store
Products Support & Training DevNet Solutions Partners Downloads Store
Home > Products > Flash > Support > TechNote Index
Macromedia Flash Support Center - TechNote

Event or methods fail after loading SWF or JPG files

Issue
Loading a SWF or JPG into a target causes event handlers and methods attached to that target to fail. If a target movie clip uses an onData event, as in the example below, loading another SWF or JPG into that target will replace the event method, causing the onData function to not fire.

For example, in the following code, the onData function will be overwritten by the loading of foo.swf, and the trace of "hello foo" will never happen.

movieClip.attachMovie ("load_mc", "myClip", 0);
loadMovie ("foo.swf", "myClip");
myClip.onData = function (){
trace ("hello foo");
}

Reason
Loading files into a target timeline replaces everything in that timeline, including actions.

Solution
One workaround is to place the event on a physical clip on the stage using onClipEvent. Please note, this solution is not useful for dynamically attached movie clips.

Another possible solution, which includes attached movie clips, involves using a movie clip nested inside another movie clip timeline as the target. The parent movie clip would be attached, and the nested movie clip would have onClipEvent already placed on the object.

This ensures that the timeline is not replaced when the movie or image file is loaded into the nested movie clip.



ID: 18776
Product: Flash
Versions: MX
OS: Windows XP, Windows 2000, Windows NT 4.0, Windows 98, Mac OS 9, Mac OS X
Browser: All
Server: None
Database: None
Former ID:  
How useful was this document?
less more

1

2

3

4

5

How can the document be improved? (300 characters or less - you will not receive a reply.)

Last updated: July 21, 2003
Created: July 21, 2003